﻿using System;

namespace RexToy.UI.Controls
{
    public class HeaderBar : Container
    {
        public override Palette Palette
        {
            get
            {
                return __palette;
            }
            set
            {
                var template = "ui-bar-{0}";
                this.__domNode.ReplaceClass(StringExt.Format(template, this.__palette), StringExt.Format(template, value));
                this.__palette = value;
            }
        }

        private string __text;
        public string Text
        {
            get { return __text; }
            set
            {
                this.__text = value;
                var dom = this.__domNode.SearchByName("content");
                dom._element.InnerHTML = this.__text;
            }
        }

        public HeaderBar(string text)
        {
            __dragEventBubble = false;
            this.__palette = Palette.A;
            this.__text = text;
            this.__domNode = RexToy.UI.Controls.DomNode.Create(new DomNodeCreateOptions()
                {
                    tag = Tag.Div,
                    className = "ui-header ui-bar-a",
                    hashName = "container",
                    items = new DomNodeCreateOptions[] {
                        new DomNodeCreateOptions()
                        {
                            tag= Tag.H1,
                            hashName= "content",
                            className= "ui-title",
                            innerHTML= text
                        }
                    }
                }
            );
        }
    }
}
